package chapter06

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/6 14:41
  * @history:
  *          1.2019/1/6 created by chuhaitao
  */
object Constructor {


  def main(args: Array[String]): Unit = {
    //var person = new Person("DS", 1)
    var person1 = new Person("tome")
    println(person1.toString)

  }
}

class Person private() {
  var name: String = _
  var age: Int = _


  override def toString: String = {
    this.name + "/" + this.age
  }

  def this(name: String) {
    //调用主要构造器
    this
    //辅助构造器
    this.name = name

  }

}